package com.atguigu.java.ai.langchain4j.controller;

import com.atguigu.java.ai.langchain4j.assistant.XiaoZhiAgent;
import com.atguigu.java.ai.langchain4j.bean.ChatForm;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

/**
 * @Author 杨轲
 * @Date 2025/5/9 19:18
 * @Version 1.0
 * @description: null
 */
@Tag(name = "硅谷小智")
@RestController
@RequestMapping("/xiaozhi")
public class XiaoZhiController {
    @Autowired
    XiaoZhiAgent xiaozhiAgent;

    /**
     * 实现患者问诊信息，智能聊天小智询问，医疗方面的具体信息
     * 比如头疼挂什么科？
     * Flux<String> 响应式布局的一部分 流式输出类型
     * @return
     */
    @Operation(summary = "智能对话" )
    @PostMapping(value = "/chat", produces = "text/stream;charset=utf-8")
    public Flux<String>  chat(@RequestBody ChatForm chatForm){
        Flux<String> chat = xiaozhiAgent.chat(chatForm.getUserId(), chatForm.getMessage());
        return chat;
    }
}
